const values_default = {
  company_id: 3001
}

const domain_default = {}

const fields_default = {
  name: null,
  company_id: null,
  start_date: null,
  limit_date: null,
  days_all: null,
  days_used: null,
  days_rest: null,
  percentage_used: null,
  state: null
}

const filterItems = [
  { type: 'input', name: 'name___like', placeholder: '名称' },
  { type: 'date', name: 'limit_date', placeholder: '账期' }
]

const columns = [
  { name: 'name', type: 'char', label: '名称' },
  { name: 'start_date', type: 'char', label: '安装日期' },
  { name: 'limit_date', type: 'char', label: '到期日期' },
  { name: 'percentage_used', type: 'char', label: '已经使用百分比' },
  { name: 'days_all', type: 'char', label: '总天数' },
  { name: 'days_used', type: 'char', label: '已使用天数' },
  { name: 'days_rest', type: 'char', label: '剩余天数' }
]

const formItems = [
  { type: 'input', name: 'name', label: '名称' },
  { type: 'date', name: 'start_date', label: '安装日期' },
  { type: 'date', name: 'limit_date', label: '到期日期' }
]

const Model = {
  configs: {
    values_default,
    domain_default,
    fields_default,
    filterItems,
    columns,
    formItems
  },

  extend: BaseClass => {
    class ModelClass extends BaseClass {
      global_domain(domain = {}) {
        return super.global_domain(domain)
      }
      search(query = {}) {
        return super.search({ ...query, order: 'percentage_used desc' })
      }
    }
    return ModelClass
  }
}

export default Model
